package com.lagou.rpc.provider;

import com.lagou.rpc.provider.server.RpcServer;
import org.I0Itec.zkclient.ZkClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@SpringBootApplication
public class ServerBootstrapApplication implements CommandLineRunner {
//public class ServerBootstrapApplication {

    @Autowired
    RpcServer rpcServer;

    @Value("${netty.port}")
    int port;

    @Value("${netty.ip}")
    String ip;

    public static void main(String[] args) {
        SpringApplication.run(ServerBootstrapApplication.class, args);
    }


    @Override
    public void run(String... args) throws Exception {
        new Thread(new Runnable() {
            @Override
            public void run() {
                rpcServer.startServer(ip, port);
            }
        }).start();

    }

}
